<HTML><HEAD><TITLE>demon +SpecList</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Predicate Database and Compiler</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>demon +SpecList</H1>
Declares the procedure(s) specified by SpecList to be demons.


<DL>
<DT><EM>SpecList</EM></DT>
<DD>Comma-separated sequence of expressions of the form Atom/Integer.
</DD>
</DL>
<H2>Description</H2>
   The demon annotation specifies that the listed predicates are to
   be treated as demons. The only difference between a normal predicate
   and a demon is the behaviour on waking: When a normal predicate is
   delayed and gets woken, the delayed goal disappears. When a delayed
   demon gets woken, the delayed goal stays around.
   The only way to remove a demon is to explicitly kill it.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>demon(++) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>SpecList is not instantiated.
<DT><EM>(5) type error </EM>
<DD>SpecList is
	instantiated, but not to a sequence of    expressions of the form Atom/Integer.
<DT><EM>(62) inconsistent procedure redefinition </EM>
<DD>Predicate in SpecList already defined and is not a demon
</DL>
<H2>Examples</H2>
<PRE>
     % A demon that wakes whenever X becomes more constrained
     report(X) :-
	     suspend(report(X, Susp), 1, X-&gt;constrained, Susp).

     :- demon report/2.
     report(X, _Susp) :-
	     var(X),
	     writeln(constrained(X)).  % implicitly re-suspend
     report(X, Susp) :-
	     nonvar(X),
	     writeln(instantiated(X)),
             kill_suspension(Susp).    % remove from the resolvent



     [eclipse 1]:  report(X),
             notify_constrained(X), wake,
             notify_constrained(X), wake.
     constrained(X)
     constrained(X)

     X = X

     Delayed goals:
                 report(X)
     yes.

     [eclipse 2]:  report(X),
             notify_constrained(X), wake,
             X=123.
     constrained(X)
     instantiated(123)

     X = 123
     yes.




</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/suspensions/kill_suspension-1.html">kill_suspension / 1</A>, <A HREF="../../kernel/suspensions/make_suspension-3.html">make_suspension / 3</A>, <A HREF="../../kernel/suspensions/notify_constrained-1.html">notify_constrained / 1</A>, <A HREF="../../kernel/suspensions/schedule_suspensions-2.html">schedule_suspensions / 2</A>, <A HREF="../../kernel/suspensions/set_suspension_data-3.html">set_suspension_data / 3</A>, <A HREF="../../kernel/suspensions/get_suspension_data-3.html">get_suspension_data / 3</A>
</BODY></HTML>
